﻿
Partial Class WebForm_Main_SearchAllTrainingCourse
    Inherits System.Web.UI.UserControl

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then

        End If
    End Sub

    Protected Sub gvTrainingCourseInfo_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles gvTrainingCourseInfo.PageIndexChanging
        Me.gvTrainingCourseInfo.PageIndex = e.NewPageIndex
        Me.BindGV()
    End Sub




End Class

Partial Class WebForm_Main_SearchAllTrainingCourse

    Public Sub BindGV()
        Dim sql As New MyStringBuilder
        Dim dat As New clsData

        sql.AppendFormat("SELECT tcg.*, isnull(tr.RegisterCount, 0) RegisterCount, cm_GroupType.Text as GroupTypeText ,ov.OrganizationName ")
        sql.AppendFormat(" from TrainingCourseGroup tcg  ")
        sql.AppendFormat("inner join CodeMapping cm_GroupType on tcg.GroupType = cm_GroupType.Value and cm_GroupType.TableName = 'TrainingCourseGroup' and cm_GroupType.ColumnName = 'GroupType' ")
        sql.AppendFormat("left join (select GroupID, Count(*) RegisterCount from TrainingRegister group by GroupID) tr on tcg.ID = tr.GroupID ")
        'sql.AppendFormat("where getdate() between tcg.RegStartDate and tcg.RegEndDate ")
        sql.AppendFormat(" inner join OrganizationView ov ON tcg.UOrganizationID = ov.UOrganizationID ")
        sql.AppendFormat(" Where 1=1 ")

        If Convert.ToString(Me.Year) <> "" Then
            sql.AppendFormat(" And Year(tcg.RegStartDate) = '{0}' ", Me.Year)
        End If

        sql.AppendFormat(" Order By tcg.StartDate  ")

        Me.gvTrainingCourseInfo.DataSource = dat.GetData(sql)
        Me.gvTrainingCourseInfo.DataBind()
    End Sub


    Public Property Year() As String
        Get
            Return ViewState("Year")
        End Get
        Set(ByVal value As String)
            ViewState("Year") = value
        End Set
    End Property

End Class
